package <%= basePackage %>.<%= moduleNameWithoutPrefix %>.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.web.page.TableDataInfo;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import <%= basePackage %>.<%= moduleNameWithoutPrefix %>.service.DemoService;

/**
 * 示例Controller
 */
@RestController
@RequestMapping("/demo")
public class DemoController extends BaseController
{
    @Autowired
    private DemoService demoService;

    /**
     * 获取示例列表
     */
    @RequiresPermissions("<%= moduleNameWithoutPrefix %>:demo:list")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        return getDataTable(demoService.selectList());
    }

    /**
     * 获取示例详细信息
     */
    @RequiresPermissions("<%= moduleNameWithoutPrefix %>:demo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(demoService.selectById(id));
    }

    /**
     * 新增示例
     */
    @RequiresPermissions("<%= moduleNameWithoutPrefix %>:demo:add")
    @Log(title = "示例管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Object demoObj)
    {
        return toAjax(demoService.insertDemo(demoObj));
    }

    /**
     * 修改示例
     */
    @RequiresPermissions("<%= moduleNameWithoutPrefix %>:demo:edit")
    @Log(title = "示例管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Object demoObj)
    {
        return toAjax(demoService.updateDemo(demoObj));
    }

    /**
     * 删除示例
     */
    @RequiresPermissions("<%= moduleNameWithoutPrefix %>:demo:remove")
    @Log(title = "示例管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(demoService.deleteByIds(ids));
    }
} 